import {baiduCountMobileArr} from '~/util/BaiDuCount.js'
export default ({app: {router}, store}) => {
  /* 每次路由变更时进行pv统计 */
  router.afterEach( ( to, from, next ) => {
    //加上try 不然会报错
    try {
      /*平台主域名统计*/
      baiduCountAllCode(baiduCountMobileArr[0].code);
    } catch (e) {

    }
  } );
}
function baiduCountAllCode(){
  var _hmt = _hmt || [];
  (function() {
    //会叠加 需要 每次执行前，先移除上次插入的代码
    document.getElementById('g_baidu') && document.getElementById('g_baidu').remove();
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?043001b8b9f659c1cbd2d9b5d46b71e0";
    hm.id = "g_baidu"
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
  })();
}
